package 练习03_多线程交互实现生产者消费者问题;

/**
 * @ClassName: ProducerThread
 * @Author: AllenSun
 * @Date: 2022/3/18 下午11:32
 */
public class ConsumerThread extends Thread {

    private MyStack<Character> stack;

    public ConsumerThread(MyStack<Character> stack, String name) {
        super(name);
        this.stack = stack;
    }

    @Override
    public void run() {
        while (true) {
            char c = stack.pull();
            System.out.println(this.getName()+" 弹出："+c);
            stack.push(c);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
